﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Reflection;
using DbGenerator.Model.units.table;
using DbExecuter.DataLayer.commands;
using System.Data.SqlClient;

namespace DbExecuter.DataLayer.executer
{
    public class TExecuter
    {
        #region ctors
        public TExecuter(TTable entityTable, SqlConnection connection)
        {
            _Connection = connection;
            _EntityTable = entityTable;
        }
        #endregion

        #region properties
        private TTable _EntityTable;
        private SqlConnection _Connection;
        #endregion

        #region public methods
        public DataTable SelectAll()
        {
            TSelectCommand selector = new TSelectCommand(_Connection);
            TSelectClause selectClause = new TSelectClause(_EntityTable.Columns.ToArray());
            TFromClause fromClause = new TFromClause(_EntityTable);
            return selector.SelectAll(selectClause, fromClause);
        }
        #endregion
    }
}
